﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Class_KetNoi
{
   public class KetNoi_HopDong:KetNoiCoSoDuLieu
    {
       public void them_HopDong( string @TenHD, string @MaNV, string @NgayBatDau, string @NgayKetThuc, string @LuongCB, string @MaCV)
       {
           SqlCommand cmd = new SqlCommand("dbo.insert_HopDong", cnn);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlParameter p = new SqlParameter("@TenHD", TenHD);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@MaNV", MaNV);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@NgayBatDau", NgayBatDau);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@NgayKetThuc", NgayKetThuc);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@LuongCB", LuongCB);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@MaCV",MaCV);
           cmd.Parameters.Add(p);
           cmd.ExecuteNonQuery();
       }
       public void sua_HopDong(string @MaloaiHD, string @TenHD, string @MaNV, string @NgayBatDau, string @NgayKetThuc, string @LuongCB, string @MaCV)
       {
           SqlCommand cmd = new SqlCommand("dbo.update_HopDong", cnn);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlParameter p = new SqlParameter("@MaloaiHD",MaloaiHD);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@TenHD", TenHD);
           cmd.Parameters.Add(p);
           p = new SqlParameter("@MaNV",Convert.ToInt32( MaNV));
           cmd.Parameters.Add(p);
           p = new SqlParameter("@NgayBatDau",Convert.ToDateTime( NgayBatDau));
           cmd.Parameters.Add(p);
           p = new SqlParameter("@NgayKetThuc", Convert.ToDateTime(NgayKetThuc));
           cmd.Parameters.Add(p);
           p = new SqlParameter("@LuongCB",Convert.ToDouble( LuongCB));
           cmd.Parameters.Add(p);
           p = new SqlParameter("@MaCV",Convert.ToInt32( MaCV));
           cmd.Parameters.Add(p);
           cmd.ExecuteNonQuery();
       }
       public void xoa_HopDong(string @MaloaiHD)
       {
           SqlCommand cmd = new SqlCommand("dbo.delete_HopDong", cnn);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlParameter p = new SqlParameter("@MaloaiHD",MaloaiHD);
           cmd.Parameters.Add(p);
           cmd.ExecuteNonQuery();
       }
       public DataTable Load_HopDong()
       {
           DataTable dt = new DataTable();
           SqlCommand cmd = new SqlCommand("Load_tbl_HopDong", cnn);
           cmd.CommandType = CommandType.StoredProcedure;
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           da.Fill(dt);
           return dt;
       }
    }
}
